/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "COMMENT_BAND")
@NamedQueries({@NamedQuery(name = "CommentBand.findAll", query = "SELECT c FROM CommentBand c"), @NamedQuery(name = "CommentBand.findByRefidcomment", query = "SELECT c FROM CommentBand c WHERE c.commentBandPK.refidcomment = :refidcomment"), @NamedQuery(name = "CommentBand.findByRefidaccount", query = "SELECT c FROM CommentBand c WHERE c.commentBandPK.refidaccount = :refidaccount"), @NamedQuery(name = "CommentBand.findByRefidband", query = "SELECT c FROM CommentBand c WHERE c.commentBandPK.refidband = :refidband")})
public class CommentBand implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CommentBandPK commentBandPK;
    @JoinColumn(name = "REFIDACCOUNT", referencedColumnName = "IDACCOUNT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Account account;
    @JoinColumn(name = "REFIDBAND", referencedColumnName = "IDBAND", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Band band;
    @JoinColumn(name = "REFIDCOMMENT", referencedColumnName = "IDCOMMENT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Comment comment;

    public CommentBand() {
    }

    public CommentBand(CommentBandPK commentBandPK) {
        this.commentBandPK = commentBandPK;
    }

    public CommentBand(int refidcomment, int refidaccount, int refidband) {
        this.commentBandPK = new CommentBandPK(refidcomment, refidaccount, refidband);
    }

    public CommentBandPK getCommentBandPK() {
        return commentBandPK;
    }

    public void setCommentBandPK(CommentBandPK commentBandPK) {
        this.commentBandPK = commentBandPK;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Band getBand() {
        return band;
    }

    public void setBand(Band band) {
        this.band = band;
    }

    public Comment getComment() {
        return comment;
    }

    public void setComment(Comment comment) {
        this.comment = comment;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commentBandPK != null ? commentBandPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CommentBand)) {
            return false;
        }
        CommentBand other = (CommentBand) object;
        if ((this.commentBandPK == null && other.commentBandPK != null) || (this.commentBandPK != null && !this.commentBandPK.equals(other.commentBandPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.CommentBand[commentBandPK=" + commentBandPK + "]";
    }

}
